Skip to content

Handle null values in children sort fields#398

Open
limenet wants to merge 1 commit into
pimcore:2.5from
limenet:patch-1
Open

Handle null values in children sort fields#398
limenet wants to merge 1 commit into
pimcore:2.5from
limenet:patch-1

Conversation

@limenet

@limenet limenet commented Mar 5, 2026

Copy link
Copy Markdown

Changes in this pull request

\Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\FieldCategory\SystemField\SystemFieldTrait::getData can return null. However, \Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\SearchResult\DataObjectSearchResultItem::setChildrenSortBy and \Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\SearchResult\DataObjectSearchResultItem::setChildrenSortOrder do not accept null and have strict types enabled.

@sonarqubecloud

sonarqubecloud Bot commented Mar 5, 2026

Copy link
Copy Markdown

@herbertroth herbertroth changed the base branch from 2.4 to 2.5 April 7, 2026 08:34
@mcop1 mcop1 added this to the 2.5.6 milestone Jul 9, 2026

@mcop1 mcop1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @limenet ,
thanks for the pr, I just thought it might be better to use the default values here? What do you think?

->setIndex(SystemField::INDEX->getData($data))
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data))
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data))
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data) ?? '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data) ?? '')
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data) ?? ?? AbstractObject::OBJECT_CHILDREN_SORT_BY_DEFAULT)

->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data))
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data))
->setChildrenSortBy(SystemField::CHILDREN_SORT_BY->getData($data) ?? '')
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data) ?? '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data) ?? '')
->setChildrenSortOrder(SystemField::CHILDREN_SORT_ORDER->getData($data) ?? AbstractObject::OBJECT_CHILDREN_SORT_ORDER_DEFAULT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants